<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>外部订单添加</title>
	<meta name="decorator" content="default"/>
	
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/bu/buExternalOrder/">外部订单列表</a></li>
		<c:choose>
				   <c:when test="${flag eq 1 and write eq 0}">
				   		<shiro:hasPermission name="bu:buExternalOrder:operate:edit"><li class="active"><a href="${ctx}/bu/buExternalOrder/form?id=${buOrder.id}&flag=1&write=0">外部订单${not empty buOrder.id?'修改':'添加'}</a></li></shiro:hasPermission>
				   </c:when>
				   <c:when test="${flag eq 2 and write eq 0}">
				   		<shiro:hasPermission name="bu:buExternalOrder:view"><li class="active"><a href="${ctx}/bu/buExternalOrder/view?id=${buOrder.id}&flag=2&write=0">外部订单查看</a></li></shiro:hasPermission>
				   </c:when>
				   <c:when test="${flag eq 3 and write eq 0}">
				   		<shiro:hasPermission name="bu:buExternalOrder:operate:copy"><li class="active"><a href="${ctx}/bu/buExternalOrder/copy?id=${buOrder.id}&flag=3&write=0">外部订单复制</a></li></shiro:hasPermission>
				   </c:when>
				   <c:when test="${flag eq 6 and write eq 1}">
				   		<shiro:hasPermission name="bu:buExternalOrder:operate:delivery"><li class="active"><a href="${ctx}/bu/buExternalOrder/selectById?id=${buOrder.id}&flag=6&write=1">外部订单填写快递信息</a></li></shiro:hasPermission>
				   </c:when>
				</c:choose>
		</li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="buOrder" action="${ctx}/bu/buExternalOrder/update" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<input type="hidden" name="flag" value="${flag}" />
		<input type="hidden" name="id" id="id" value="${id}"/>
		<input type="hidden" name="orderState" id="orderState" value="${orderState}"/>
		<sys:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">订单编号：</label>
			<div class="controls">
				<form:input path="orderNo" readonly="true" htmlEscape="false" maxlength="64" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">生产编号：</label>
			<div class="controls">
				<form:input path="productNo" onkeydown="changeFocus()" htmlEscape="false" maxlength="64" class="required input-xlarge "/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">客户订单编号：</label>
			<div class="controls">
				<form:input path="customerOrderNo" onkeydown="changeFocus()" htmlEscape="false" maxlength="64" class="required input-xlarge "/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">下单日期：</label>
			<div class="controls">
				<form:input path="orderDate" readonly="true" htmlEscape="false" maxlength="64" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">出货日期：</label>
			<div class="controls">
				<input name="shipDate" type="text" maxlength="20" class="input-medium Wdate "
					value="<fmt:formatDate value="${buOrder.shipDate}" pattern="yyyy-MM-dd"/>"
					onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});"/>
					<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">产品名称：</label>
			<div class="controls">
				<form:input path="productName" onkeydown="changeFocus()" htmlEscape="false" maxlength="64" class="required input-xlarge "/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">工艺：</label>
			<div class="controls">
				<form:input path="crafts" onkeydown="changeFocus()" htmlEscape="false" maxlength="64" class="required input-xlarge "/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
				<label class="control-label">是否初订：</label>
				<div class="controls">
					<form:radiobuttons path="status" items="${fns:getDictList('order_status')}" itemLabel="label" itemValue="value" htmlEscape="false" class="required"/>
					<span class="help-inline"><font color="red">*</font> </span>
				</div>
			</div>
		<div class="control-group">
			<label class="control-label">抛光：</label>
			<div class="controls">
				<form:input path="polishing" onkeydown="changeFocus()" htmlEscape="false" maxlength="64" class="required input-xlarge "/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">电镀：</label>
			<div class="controls">
				<form:input path="electroplate" onkeydown="changeFocus()" htmlEscape="false" maxlength="64" class="required input-xlarge "/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">背面：</label>
			<div class="controls">
				<form:input path="back" onkeydown="changeFocus()" htmlEscape="false" maxlength="64" class="required input-xlarge "/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">包装：</label>
			<div class="controls">
				<form:input path="packages" onkeydown="changeFocus()" htmlEscape="false" maxlength="64" class="required input-xlarge "/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">配件：</label>
			<div class="controls">
				<form:input path="fitting" onkeydown="changeFocus()" htmlEscape="false" maxlength="64" class="required input-xlarge "/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">材质：</label>
			<div class="controls">
				<form:input path="material" onkeydown="changeFocus()" htmlEscape="false" maxlength="64" class="required input-xlarge "/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">图片：</label>
			<div class="controls">
				    <input type="file" id="file" name="myfile" onchange="aa()"/>
				    <input type="hidden" name="picUrl" id="picUrl" class="required input-xlarge ">
					<img src="" alt="" id="avatarShow" width="500px" height="750px">
					<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">尺寸：</label>
			<div class="controls">
				<form:input path="productSize" onkeydown="changeFocus()" htmlEscape="false" maxlength="64" class="required input-xlarge "/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">厚度：</label>
			<div class="controls">
				<form:input path="thinkness" onkeydown="changeFocus()" htmlEscape="false" maxlength="64" class="required input-xlarge "/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">快递单名称：</label>
			<div class="controls">
				<form:input path="deliveryName" readonly="true" htmlEscape="false" maxlength="64" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">快递单号：</label>
			<div class="controls">
				<form:input path="deliveryNumber" readonly="true" htmlEscape="false" maxlength="64" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">运费：</label>
			<div class="controls">
				<form:input path="freight" readonly="true" htmlEscape="false" maxlength="64" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">数量：</label>
			<div class="controls">
				<form:input path="quantity" onkeydown="changeFocus()" htmlEscape="false" maxlength="11" class="required input-xlarge " id="quantity"
				onkeyup="value=value.replace(/[^\d]/g,'')"/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">销售单价：</label>
			<div class="controls">
				<form:input path="salesPrice" onkeydown="changeFocus()" onkeyup="keepNumOrDecimal(this)" maxlength="12" htmlEscape="false" class="required input-xlarge" id="salesPrice"
				/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">销售模费：</label>
			<div class="controls">
				<form:input path="salesModelFee" onkeydown="changeFocus()" onkeyup="keepNumOrDecimal(this)" maxlength="12" htmlEscape="false" class="required input-xlarge " id="salesModelFee" 
				/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">生产单价：</label>
			<div class="controls">
				<form:input path="produceFee" onkeydown="changeFocus()" onkeyup="keepNumOrDecimal(this)" maxlength="12" htmlEscape="false" class="required input-xlarge " id="produceFee" 
				/>
			    <span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">生产模费：</label>
			<div class="controls">
				<form:input path="produceModelFee" onkeydown="changeFocus()" onkeyup="keepNumOrDecimal(this)" maxlength="12" htmlEscape="false" class="required input-xlarge " id="produceModelFee" 
				/>
				<span class="help-inline"><font color="red">*</font> </span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">销售总价：</label>
			<div class="controls">
				<form:input path="salesTotalFee" readonly="true" htmlEscape="false" class="input-xlarge " id="salesTotalFee"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">生产总价：</label>
			<div class="controls">
				<form:input path="produceTotalFee" readonly="true" htmlEscape="false" class="input-xlarge " id="produceTotalFee"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">利润：</label>
			<div class="controls">
				<form:input path="profit" readonly="true" htmlEscape="false" class="input-xlarge " id="profit" name="profit"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">业务员名称：</label>
			<div class="controls">
				<form:select path="customerId" id="customerId" name="customerId" class="input-xlarge " onchange="changSalesMan(this.options[this.options.selectedIndex].value)">
					<form:option value="" label=""/>
					<form:options items="${customerList}" itemLabel="name" itemValue="id" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">客户名称：</label>
			<div class="controls">
				<form:select id="salesmanId" name="salesmanId" path="salesmanId" class="input-xlarge" onmousedown="changSalesManOfMy(this.options[this.options.selectedIndex].value)">
					<form:options items="${entityList}" itemLabel="salesmanName" itemValue="id" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">供应商名称：</label>
			<div class="controls">
				<form:select path="supplierId" id="supplierId" name="supplierId" class="input-xlarge" onmousedown="changSupplier(this.options[this.options.selectedIndex].value)">
					<form:option value="" label=""/>
					<form:options items="${supplierList}" itemLabel="name" itemValue="id" htmlEscape="false"/>
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">创建人：</label>
			<div class="controls">
				<form:input path="createUser" readonly="true" htmlEscape="false" maxlength="64" class="input-xlarge "/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">备注：</label>
			<div class="controls">
				<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="255" class="input-xxlarge "/>
			</div>
		</div>
		<div class="form-actions">
		   <c:if test="${flag == 0 || flag == 1}">
		   		<shiro:hasPermission name="bu:buExternalOrder:operate:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
		   </c:if>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
	<script type="text/javascript">
		$(document).ready(function(){
			    console.log("111111111111111111111111111111111");
				var picUrl = '${buOrder.picUrl}';
				var picPrefix = '${picPrefix}';
				console.log("aaaa             " , picUrl);
				$("#picUrl").attr("value",picUrl);
				$("#avatarShow").attr("src",picPrefix + picUrl);	
		});
	
	</script>
	<script type="text/javascript">
	function aa(){
		console.log("aaaaaaaaaaa            ",$("#file").val());
		if($("#file").val() != ""){
			var formData = new FormData();
	        formData.append('file',$("#file")[0].files[0]);    //将文件转成二进制形式
			$.ajax({
					 url:"${ctx}/file/uploadFile",
				      data: formData,   //请求参数
					  type: 'POST',  //请求类型
					  dataType:'text',
					  async:false,
					  contentType: false,//没有设置任何内容类型头信息
					  processData: false, //见jQuery_api详解
					  beforeSend: function(){
						 
					 },
				     success: function(data){
					    var json = eval('(' + data + ')'); 
					    console.log("json          ",json);
					    console.log("json          ",json.preffix);
					    //图片显示
						$("#picUrl").attr("value",json.val);
						$("#avatarShow").attr("src",json.preffix+json.val);	
				     },
				     error: function (jqXHR,textStatus,errorThrown) {
				     	alert("上传失败");
				     },
				 });
			}else{
				console.log("222222222222222222");
			}
		}
	</script>
	<script type="text/javascript">
	  function changeFocus(){
	       if(event.keyCode==13)
	          event.keyCode=9;
	    }
	 function changSalesMan(v,w){
		   console.log(v,w);
			    $.ajax({
			        type : "post",
			        async : false,
			        url : "${ctx}/bu/buExternalOrder/selectButtonSalesList",
			        data : {
			            'id': v,
			            'orderId': w
			        },
			        dataType : "json",
			        success : function(msg) {
			            $("#salesmanId").empty();
			            console.log(msg.salesmanId.length);
			            if (msg.salesmanId.length > 0) {
			                for (var i = 0; i < msg.salesmanId.length; i++) {
			                        var partId = msg.salesmanId[i].id;
			                        var partName = msg.salesmanId[i].salesmanName;
			                        var $option = $("<option>").attr({
			                            "value" : partId
			                        }).text(partName);
			                        console.log($option);
			                        $("#salesmanId").append($option);
			                }
			        }else{
			        	$("#salesmanId").empty();
			        }
			    }, error : function(json) {
		            $.jBox.alert("网络异常！");
		        }
			    })
	   }
	 
	 function changSalesManOfMy(v,w){
			    $.ajax({
			        type : "post",
			        async : false,
			        url : "${ctx}/bu/buExternalOrder/selectButtonSalesListOfBy",
			        data : {
			            'id': v,
			            "orderId": w
			        },
			        dataType : "json",
			        success : function(msg) {
			            $("#salesmanId").empty();
			            console.log(msg.salesmanId.length);
			            if (msg.salesmanId.length > 0) {
			                for (var i = 0; i < msg.salesmanId.length; i++) {
			                        var partId = msg.salesmanId[i].id;
			                        var partName = msg.salesmanId[i].salesmanName;
			                        
			                        if(msg.salesmanId[i].isRef == 1){
			                        	var $option = $("<option>").attr({"value": partId
			                        		}).text(partName).attr("selected","selected");
			                        }else{
			                        	var $option = $("<option>").attr({
				                            "value" : partId
				                        }).text(partName);
			                        }
			                        console.log($option);
			                        $("#salesmanId").append($option);
			                }
			        }else{
			        	$("#salesmanId").empty();
			        }
			    }, error : function(json) {
		            $.jBox.alert("网络异常！");
		        }
			    })
	   }
	 
	 function changSupplier(param){
			    $.ajax({
			        type : "post",
			        async : false,
			        url : "${ctx}/bu/buExternalOrder/changSupplier",
			        data : {
			        	"id": param
			        },
			        dataType : "json",
			        success : function(msg) {
			        	console.log("msg         "+msg);
			            $("#supplierId").empty();
			            console.log(msg.supplierList.length);
			            if (msg.supplierList.length > 0) {
			                for (var i = 0; i < msg.supplierList.length; i++) {
			                        var partId = msg.supplierList[i].id;
			                        var partName = msg.supplierList[i].name;
			                        if(msg.supplierList[i].isRef == 1){
			                        	var $option = $("<option>").attr({
				                            "value" : partId
				                        }).text(partName).attr('selected','selected');
			                        }else{
				                        var $option = $("<option>").attr({
				                            "value" : partId
				                        }).text(partName);	
			                        }
			                        console.log($option);
			                        $("#supplierId").append($option);
			                }
			        }else{
			        	$("#supplierId").empty();
			        }
			    }, error : function(json) {
		            $.jBox.alert("网络异常！");
		        }
			    })
	   }
	
		$(document).ready(function() {
				console.log("123");
				var customerId = $("#customerId").find("option:selected").val();
				var orderId = $("#id").val();
				changSalesManOfMy(customerId,orderId);
				//changSalesMan(customerId,orderId);
				//$("#salesmanId").get(0).selectedIndex;
				changSupplier(orderId);
				<shiro:hasPermission name="bu:buExternalOrder:operate:isSalesSel">
						$("#salesmanId").prop("disabled", false);
				</shiro:hasPermission>
				<shiro:hasPermission name="bu:buExternalOrder:operate:isNotSalesSel">
						$("#salesmanId").prop("disabled", true);
				</shiro:hasPermission>
				<shiro:hasPermission name="bu:buExternalOrder:operate:isSupplierSel">
						$("#supplierId").prop("disabled", false);
				</shiro:hasPermission>
				<shiro:hasPermission name="bu:buExternalOrder:operate:isNotSupplierSel">
						$("#supplierId").prop("disabled", true);
				</shiro:hasPermission>
				$("#customerId").prop("disabled", true);
			
			var sp = 0; 
			var smf = 0;
			$("#quantity").bind("input propertychange",function () {
			  console.log("quantity");
			  var num = $("#quantity").val();
			  var a1 = $("#salesPrice").val();
			  var b1 = $("#salesModelFee").val();
			  var c1 = $("#produceFee").val();
			  var d1 = $("#produceModelFee").val();
			  console.log("num",num);
			  console.log("a1",a1);
			  console.log("b1",b1);
			  console.log("c1",c1);
			  console.log("d1",d1);
			  sp = ((parseFloat(a1) * parseFloat(num)) + parseFloat(b1)).toFixed(2);
			  smf = ((parseFloat(c1) * parseFloat(num)) + parseFloat(d1)).toFixed(2);
			  
			  if(isNaN(smf) && isNaN(smf)){ 
				    smf = 0; 
				 }
			  if(isNaN(sp) && isNaN(sp)){
				  sp = 0;
			  }
			  
			  console.log("sp",sp);
			  console.log("smf",smf);
			  backSp();
			  backSmf();
			});
			
			$("#salesPrice").bind("input propertychange",function(){
				console.log("salesPrice");
				var num = $("#quantity").val();
				var a1 = $("#salesPrice").val();
				var b1 = $("#salesModelFee").val();
				console.log("num",num);
				console.log("a1",a1);
				console.log("b1",b1);
				sp = ((parseFloat(a1) * parseFloat(num)) + parseFloat(b1)).toFixed(2);
				  if(isNaN(sp) && isNaN(sp)){
					  sp = 0;
				  }
				console.log("sp",sp);
				backSp();
			});
			$("#salesModelFee").bind("input propertychange",function(){
				console.log("salesModelFee");
				var num = $("#quantity").val();
				var a1 = $("#salesPrice").val();
				var b1 = $("#salesModelFee").val(); 
				console.log("num",num);
				console.log("a1",a1);
				console.log("b1",b1);
				sp = ((parseFloat(a1) * parseFloat(num)) + parseFloat(b1)).toFixed(2);
			  if(isNaN(sp) && isNaN(sp)){
				  sp = 0;
			  }
				console.log("sp",sp);
				backSp();
			});
			
			$("#produceFee").bind("input propertychange",function () { 
			    console.log("produceFee");
			    var num = $("#quantity").val();
				var a1 = $("#produceFee").val();
				var b1 = $("#produceModelFee").val();  
				smf = ((parseFloat(a1) * parseFloat(num)) + parseFloat(b1)).toFixed(2);
				if(isNaN(smf) && isNaN(smf)){ 
				    smf = 0; 
				 }
				console.log("num",num);
				console.log("a1",a1);
				console.log("b1",b1);
				console.log("smf",smf);
				backSmf();
			});
			
			$("#produceModelFee").bind("input propertychange",function () { 
			    console.log("produceModelFee");
			    var num = $("#quantity").val();
				var a1 = $("#produceFee").val();
				var b1 = $("#produceModelFee").val();  
				console.log("num",num);
				console.log("a1",a1);
				console.log("b1",b1);
				smf = ((parseFloat(a1) * parseFloat(num)) + parseFloat(b1)).toFixed(2);
				if(isNaN(smf) && isNaN(smf)){ 
				    smf = 0; 
				 }
				console.log("smf",smf);
				backSmf();
			});
			
			function backSp(){   
			  $("#salesTotalFee").val(sp);
			  var salesTotalFee = $("#salesTotalFee").val();
			  var produceTotalFee = $("#produceTotalFee").val();
			  var profit = (parseFloat(salesTotalFee) - parseFloat(produceTotalFee)).toFixed(2);
			  console.log("profit",profit);
			  $("#profit").val(profit);
			}
			function backSmf(){
			  $("#produceTotalFee").val(smf);
			  var salesTotalFee = $("#salesTotalFee").val();
			  var produceTotalFee = $("#produceTotalFee").val();
			  var profit = (parseFloat(salesTotalFee) - parseFloat(produceTotalFee)).toFixed(2);
			  console.log("profit",profit);
			  $("#profit").val(profit);
			}
			
			$("#shipDate").focus();
			$("#productName").focus();
			$("#crafts").focus();
			$("#polishing").focus();
			$("#electroplate").focus();
			$("#back").focus();
			$("#packages").focus();
			$("#fitting").focus();
			
			$("#picUrl").focus();
			$("#quantity").focus();
			$("#salesPrice").focus();
			
			$("#salesModelFee").focus();
			$("#produceFee").focus();
			$("#produceModelFee").focus();
			$("#salesTotalFee").focus();
			$("#material").focus();
			
			$("#produceTotalFee").focus();
			$("#profit").focus();
			$("#customerId").focus();
			$("#salesmanId").focus();
			$("#supplierId").focus();
			$("#customerOrderNo").focus();
			$("#productSize").focus();
			$("#thinkness").focus();
			
			$("#productNo").focus();
				$("#inputForm").validate({
					submitHandler: function(form){
						$("#salesmanId").prop("disabled", false);
						$("#supplierId").prop("disabled", false);
						$("#customerId").prop("disabled",false);
						loading('正在提交，请稍等...');
						form.submit();
					},
					errorContainer: "#messageBox",
					errorPlacement: function(error, element) {
						$("#messageBox").text("输入有误，请先更正。");
						if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
							error.appendTo(element.parent().parent());
						} else {
							error.insertAfter(element);
						}
					}
				});
		});
		function addRow(list, idx, tpl, row){
			$(list).append(Mustache.render(tpl, {
				idx: idx, delBtn: true, row: row
			}));
			$(list+idx).find("select").each(function(){
				$(this).val($(this).attr("data-value"));
			});
			$(list+idx).find("input[type='checkbox'], input[type='radio']").each(function(){
				var ss = $(this).attr("data-value").split(',');
				for (var i=0; i<ss.length; i++){
					if($(this).val() == ss[i]){
						$(this).attr("checked","checked");
					}
				}
			});
		}
		
		function check(e) { 
		    var re = /^\d+(?=\.{0,1}\d+$|$)/ 
		    if (e.value != "") { 
		        if (!re.test(e.value)) { 
		            alert("请输入正确的数字"); 
		            e.value = ""; 
		            e.focus(); 
		        } 
		    } 
		}
		
		function delRow(obj, prefix){
			var id = $(prefix+"_id");
			var delFlag = $(prefix+"_delFlag");
			if (id.val() == ""){
				$(obj).parent().parent().remove();
			}else if(delFlag.val() == "0"){
				delFlag.val("1");
				$(obj).html("&divide;").attr("title", "撤销删除");
				$(obj).parent().parent().addClass("error");
			}else if(delFlag.val() == "1"){
				delFlag.val("0");
				$(obj).html("&times;").attr("title", "删除");
				$(obj).parent().parent().removeClass("error");
			}
		}
		// 只能入力数字和小数点  
		function keepNumOrDecimal(obj) {  
		    //先把非数字的都替换掉，除了数字和.  
		    obj.value = obj.value.replace(/[^\d.]/g,"");  
		    //必须保证第一个为数字而不是.  
		    obj.value = obj.value.replace(/^\./g,"");  
		    //保证只有出现一个.而没有多个.  
		    obj.value = obj.value.replace(/\.{2,}/g,".");  
		    //保证.只出现一次，而不能出现两次以上  
		    obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");  
		}  
	</script>
</body>
</html>